package com.step.graphic;

import java.util.ArrayList;
import java.util.HashMap;

import com.step.GameActivity;
import com.step.Step;

class TextureManager {
	static final HashMap<GameActivity, ArrayList<Texture>> managedTextures = new HashMap<GameActivity, ArrayList<Texture>>();
	
	static void addManagedTexture (GameActivity app, Texture texture) {
		ArrayList<Texture> managedTexureList = managedTextures.get(app);
		if (managedTexureList == null) managedTexureList = new ArrayList<Texture>();
		managedTexureList.add(texture);
		managedTextures.put(app, managedTexureList);
	}

	/** 清除所有纹理，内部方法，不要调用它 */
	public static void clearAllTextures (GameActivity app) {
		managedTextures.remove(app);
	}
	
	public static String getManagedStatus () {
		StringBuilder builder = new StringBuilder();
		builder.append("Managed textures/app: { ");
		for (GameActivity app : managedTextures.keySet()) {
			builder.append(managedTextures.get(app).size());
			builder.append(" ");
		}
		builder.append("}");
		return builder.toString();
	}
	
	public static int getNumManagedTextures() {
		return managedTextures.get(Step.context).size();
	}
}
